home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Art Attack: My Stuff
/
Art Attack - My Stuff (2006)(Kellogg's).iso
/
data1.cab
/
Showme
/
instructions.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2006-04-28
|
6KB
|
273 lines
function init(screen)
{
screenRef = screen;
discNum = Number(screenRef.charAt(1));
xmlData.load("data.xml");
reset();
holder_mc._xscale = 70;
holder_mc._yscale = 70;
}
function promptNextPart()
{
trace("animate button: btn" + Number(curPart + 1));
this["btn" + (curPart + 1)].gotoAndPlay("prompt");
this["btn" + (curPart + 1)].isPrompting = true;
}
function loadPart()
{
if(curPart < 10)
{
trace("loading: " + aAnim.attributes.id + "_0" + curPart);
loader.loadClip(swfPath + aAnim.attributes.id + "_0" + curPart + ".swf",holder_mc);
}
else
{
trace("loading: " + aAnim.attributes.id + "_" + curPart);
loader.loadClip(swfPath + aAnim.attributes.id + "_" + curPart + ".swf",holder_mc);
}
}
function setButtons()
{
if(numParts > 1)
{
i = 1;
while(i <= numParts)
{
this["btn" + i]._visible = true;
this["btn" + i].myText.gotoAndStop(i);
i++;
}
}
}
function resetButtons()
{
i = 1;
while(i <= 8)
{
this["btn" + i].gotoAndStop(1);
i++;
}
}
function reset()
{
curPart = 1;
i = 1;
while(i <= 8)
{
this["btn" + i]._visible = false;
i++;
}
}
function togglePlaying()
{
if(isPlaying)
{
isPlaying = false;
holder_mc.stop();
playpause_btn.gotoAndStop("pause_n");
}
else
{
isPlaying = true;
if(isEnded)
{
playAnim();
}
else
{
holder_mc.play();
}
playpause_btn.gotoAndStop("play_n");
}
}
function playAnim()
{
playpause_btn.gotoAndStop("play_n");
isPlaying = true;
isEnded = false;
holder_mc.onEnterFrame = function()
{
if(this._currentframe == this._totalframes)
{
this.stop();
delete this.onEnterFrame;
isPlaying = false;
isEnded = true;
playpause_btn.gotoAndStop("pause_n");
promptNextPart();
}
};
part_txt.text = "Part " + curPart + " of " + numParts;
holder_mc.play();
}
function stopRewind()
{
rewinding = false;
trace("rewind stopped");
clearInterval(intervalID);
}
function showTooltip(tip, button)
{
trace(tip);
clearInterval(tooltipInterval);
tooltip_mc.text_txt.text = tip;
tooltip_mc.bg._width = tooltip_mc.text_txt._width + 10;
tooltip_mc._x = button._x;
tooltip_mc.bg._x = - tooltip_mc.bg._width / 2;
}
var discNum;
var screenRef;
var swfPath;
var curPart;
var xmlData = new XML();
var aCD = new Array();
var aAnim = new Array();
var numParts;
var loader = new MovieClipLoader();
var listener = new Object();
var isPlaying;
var isEnded;
var rewinding = false;
var intervalID;
var tooltipInterval;
var tooltipDelay = 0.5;
var rewindCount;
loader.addListener(listener);
xmlData.ignoreWhite = true;
listener.onLoadInit = function()
{
trace("loaded!");
playAnim();
};
restart_btn.onRollOver = function()
{
tooltipInterval = setInterval(showTooltip,tooltipDelay * 1000,"Back to Start",this);
this.gotoAndStop(2);
};
restart_btn.onRollOut = restart_btn.onDragOut = function()
{
this.gotoAndStop(1);
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
restart_btn.onPress = function()
{
curPart = 1;
loadPart();
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
rewind_btn.onRollOver = function()
{
tooltipInterval = setInterval(showTooltip,tooltipDelay * 1000,"Back",this);
this.gotoAndStop(2);
};
rewind_btn.onRollOut = rewind_btn.onDragOut = function()
{
this.gotoAndStop(1);
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
rewind_btn.onPress = function()
{
if(!rewinding)
{
rewinding = true;
intervalID = setInterval(stopRewind,500);
holder_mc.gotoAndStop(1);
togglePlaying();
}
else
{
clearInterval(intervalID);
rewinding = false;
if(curPart > 1)
{
curPart--;
loadPart();
}
}
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
playpause_btn.onRollOver = function()
{
tooltipInterval = setInterval(showTooltip,tooltipDelay * 1000,"Play/Pause",this);
if(isPlaying)
{
this.gotoAndStop("play_r");
}
else
{
this.gotoAndStop("pause_r");
}
};
playpause_btn.onRollOut = playpause_btn.onDragOut = function()
{
if(isPlaying)
{
this.gotoAndStop("play_n");
}
else
{
this.gotoAndStop("pause_n");
}
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
playpause_btn.onPress = function()
{
togglePlaying();
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
fastforward_btn.onRollOver = function()
{
tooltipInterval = setInterval(showTooltip,tooltipDelay * 1000,"Forward",this);
this.gotoAndStop(2);
};
fastforward_btn.onRollOut = fastforward_btn.onDragOut = function()
{
this.gotoAndStop(1);
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
fastforward_btn.onPress = function()
{
if(numParts != curPart)
{
curPart++;
loadPart();
}
clearInterval(tooltipInterval);
tooltip_mc._x = -100;
};
xmlData.onLoad = function(success)
{
if(success)
{
aCD = xmlData.firstChild.childNodes[discNum - 1].childNodes;
i = 0;
while(i < aCD.length)
{
if(aCD[i].attributes.id == screenRef)
{
aAnim = aCD[i];
}
i++;
}
swfPath = xmlData.firstChild.attributes.swfPath;
numParts = aAnim.attributes.numParts;
trace("animation: " + aAnim.attributes.title);
trace("number of parts: " + numParts);
if(numParts == 1)
{
fastforward_btn._visible = false;
restart_btn._visible = false;
}
setButtons();
loadPart();
}
};
tooltip_mc.text_txt.autoSize = "center";